home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_10_01
/
cmenu.exe
/
SAGA.TXT
< prev
Wrap
Text File
|
1991-12-18
|
3KB
|
53 lines
========================================================================
This file contains a correction to the Illustrated C column that appears
in the January 1992 issue of CUJ. The section titled "The Saga of
Pathname Delimiters" contained some out-of-date information. This is the
text which should have appeared in that section. -lz
========================================================================
The Saga of Pathname Delimiters
-------------------------------
Even after years of programming in C under DOS, I still occasionally
forget double up the backslashes in pathname strings. For example, I
may have a statement at the top of my C program that looks something
like:
#define PATH "c:\foo\bar"
The compiler sees a string containing c:, a formfeed, oo, a
backspace, and ar. This is clearly not the intended result. What I
really meant to write was:
#define PATH "c:\\foo\\bar"
This kind of goof draws no compilation errors; often, it isn't until
after I've become thoroughly confused and fired up the debugger that
I find the error. To allow the use of the single backslash character
in CMENU source files and avoid the need for the double-backslash
notation, I decided that the backslash character would not have any
special meaning in the CMENU specification language. As described
above in the section on strings, there is no notation for escape
sequences and single backslashes in pathnames are taken literally.
While DOS uses the backslash (\) to delimit subdirectories in
pathnames, UNIX-like systems use the forward slash (/). The CMENU
language supports the use of the forward slash (/) to delimit
pathnames under DOS, as well. The rmenu program processes all DOS
pathname strings through a function named trans_slash() (Listing
8.11, lines 94-112) to convert forward slashes into backslashes. This
reduces the amount of revision required to move a CMENU specification
between DOS and UNIX systems.
To allow the forward slash character to appear in system commands
(for example, as part of an option string to a DOS application
program), action text is not processed by trans_slash(). A pathname
written with forward slashes acceptable in a DOS path statement, but
will not work in a DOS action clause.
The net result of all this is the following rule of thumb: under DOS,
to be absolutely safe always use backslashes. If you prefer to use
forward-slashes, then use them only in path clauses, never in an
action clause.